using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace ns20
{
	internal static class Class187
	{
		[CompilerGenerated]
		private static Func<FieldInfo, bool> func_0;

		[CompilerGenerated]
		private static Func<FieldInfo, bool> func_1;

		public static IList<T> smethod_0<T>(T gparam_0) where T : struct
		{
			Type typeFromHandle = typeof(T);
			if (!typeFromHandle.IsDefined(typeof(FlagsAttribute), inherit: false))
			{
				throw new ArgumentException("Enum type {0} is not a set of flags.".smethod_0(CultureInfo.InvariantCulture, typeFromHandle));
			}
			Type underlyingType = Enum.GetUnderlyingType(gparam_0.GetType());
			ulong num = Convert.ToUInt64(gparam_0, CultureInfo.InvariantCulture);
			Class189<ulong> @class = smethod_1<T>();
			IList<T> list = new List<T>();
			foreach (Class188<ulong> item in @class)
			{
				if ((num & item.Prop_0) == item.Prop_0 && item.Prop_0 != 0L)
				{
					list.Add((T)Convert.ChangeType(item.Prop_0, underlyingType, CultureInfo.CurrentCulture));
				}
			}
			if (list.Count == 0 && @class.SingleOrDefault((Class188<ulong> class188_0) => class188_0.Prop_0 == 0L) != null)
			{
				list.Add(default(T));
			}
			return list;
		}

		public static Class189<ulong> smethod_1<T>() where T : struct
		{
			return smethod_2<ulong>(typeof(T));
		}

		public static Class189<T> smethod_2<T>(Type type_0) where T : struct
		{
			if (type_0 == null)
			{
				throw new ArgumentNullException("enumType");
			}
			Class204.smethod_1(type_0, "enumType");
			IList<object> list = smethod_3(type_0);
			IList<string> list2 = smethod_4(type_0);
			Class189<T> @class = new Class189<T>();
			for (int i = 0; i < list.Count; i++)
			{
				try
				{
					@class.Add(new Class188<T>(list2[i], (T)Convert.ChangeType(list[i], typeof(T), CultureInfo.CurrentCulture)));
				}
				catch (OverflowException innerException)
				{
					throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Value from enum with the underlying type of {0} cannot be added to dictionary with a value type of {1}. Value was too large: {2}", new object[3]
					{
						Enum.GetUnderlyingType(type_0),
						typeof(T),
						Convert.ToUInt64(list[i], CultureInfo.InvariantCulture)
					}), innerException);
				}
			}
			return @class;
		}

		public static IList<object> smethod_3(Type type_0)
		{
			if (!type_0.smethod_7())
			{
				throw new ArgumentException("Type '" + type_0.Name + "' is not an enum.");
			}
			List<object> list = new List<object>();
			IEnumerable<FieldInfo> enumerable = from fieldInfo_0 in type_0.GetFields()
				where fieldInfo_0.IsLiteral
				select fieldInfo_0;
			foreach (FieldInfo item in enumerable)
			{
				object value = item.GetValue(type_0);
				list.Add(value);
			}
			return list;
		}

		public static IList<string> smethod_4(Type type_0)
		{
			if (!type_0.smethod_7())
			{
				throw new ArgumentException("Type '" + type_0.Name + "' is not an enum.");
			}
			List<string> list = new List<string>();
			IEnumerable<FieldInfo> enumerable = from fieldInfo_0 in type_0.GetFields()
				where fieldInfo_0.IsLiteral
				select fieldInfo_0;
			foreach (FieldInfo item in enumerable)
			{
				list.Add(item.Name);
			}
			return list;
		}

		[CompilerGenerated]
		private static bool smethod_5<T>(Class188<ulong> class188_0) where T : struct
		{
			return class188_0.Prop_0 == 0L;
		}

		[CompilerGenerated]
		private static bool smethod_6(FieldInfo fieldInfo_0)
		{
			return fieldInfo_0.IsLiteral;
		}

		[CompilerGenerated]
		private static bool smethod_7(FieldInfo fieldInfo_0)
		{
			return fieldInfo_0.IsLiteral;
		}
	}
}
